<!doctype html>
<html lang="{{ app()->getLocale() }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>Laravel</title>


        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

        <!-- Styles -->
        <style>
            html, body {
                background-color: #fff;
                color: #636b6f;
                font-family: 'Raleway', sans-serif;
                font-weight: 100;
                height: 100vh;
                margin: 0;
            }

            .full-height {
                height: 100vh;
            }

            .flex-center {
                align-items: center;
                display: flex;
                justify-content: center;
            }

            .position-ref {
                position: relative;
            }

            .top-right {
                position: absolute;
                right: 10px;
                top: 18px;
            }

            .content {
                text-align: center;
            }

            .title {
                font-size: 84px;
            }

            .links > a {
                color: #636b6f;
                padding: 0 25px;
                font-size: 12px;
                font-weight: 600;
                letter-spacing: .1rem;
                text-decoration: none;
                text-transform: uppercase;
            }

            .m-b-md {
                margin-bottom: 30px;
            }

            .book-content{
                font-size: 21px;

            }
        </style>
    </head>
    <body>
        <div class="flex-center position-ref full-height">
            @if (Route::has('login'))
                <div class="top-right links">
                    @auth
                        <a href="{{ url('/home') }}">Home</a>
                    @else
                        <a href="{{ route('login') }}">Login</a>
                        <a href="{{ route('register') }}">Register</a>
                    @endauth
                </div>
            @endif

            <div class="content">
                <div class="title m-b-md">
                    Laravel
                </div>

                <ul id="sss">
                    <li>111</li>
                    <li>111</li>
                    <li>111</li>
                    <li>
                        111
                        <div>
                            other
                            <div class="other">

                                <p id="current"></p>
                            </div>
                        </div>

                        <div>
                            <div class="comment"  style="width: 200px;height: 200px;background-color: red"></div>
                        </div>

                    </li>
                    <li>
                        111
                    </li>
                    <li>111</li>
                    <li>111</li>

                </ul>



                <div  class="links">
                    <a href="https://laravel.com/docs">Documentation</a>
                    <a href="https://laracasts.com">Laracasts</a>
                    <a href="https://laravel-news.com">News</a>
                    <a href="https://forge.laravel.com">Forge</a>
                    <a href="https://github.com/laravel/laravel">GitHub</a>
                </div>

                {{--<p id="labelMode" style="font-size: 10px">舒服舒服</p>--}}
                <p id="labelMode" class="book-content">啥代号四大行</p>
                <div class="other" style="padding-top: 30px">
                    <button onclick="openWindow()">打开窗口</button>
                </div>
            </div>
        </div>
        <img src="	http://test-1251628786.coscd.myqcloud.com/test/mKZHyZq6oUpH8eefEssMSYxymOt7hoq1xvMaEaAw.jpeg" alt="">
    </body>
</html>

<script src="{{ asset('js/app.js') }}"></script>



<script>

    let li = document.getElementById('sss');
    console.log(li)
    console.log(li.childNodes)
    console.log(li.children)

    function  initialize() {
        this.accessToken = localStorage.getItem('access_token');
        this.refreshToken = localStorage.getItem('refresh_token');
        let token = 'Bearer '+ this.accessToken;

        axios.defaults.headers.common['Authorization'] = token;
    }

    var token = 'Bearer '+'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImZhNGRmNGQ4YWE3NjFlMzI2ZDczMzRjODI4MmIzOTk5ODYzOTFlNGRjYjQyYTM1MTVhNmNhNGVhNmZhMjgyYzVmOGU1NmY3MGM2NTk3NTE0In0.eyJhdWQiOiIyIiwianRpIjoiZmE0ZGY0ZDhhYTc2MWUzMjZkNzMzNGM4MjgyYjM5OTk4NjM5MWU0ZGNiNDJhMzUxNWE2Y2E0ZWE2ZmEyODJjNWY4ZTU2ZjcwYzY1OTc1MTQiLCJpYXQiOjE1MDY1ODQzMjcsIm5iZiI6MTUwNjU4NDMyNywiZXhwIjoxNTA3ODgwMzI3LCJzdWIiOiI4MzkwIiwic2NvcGVzIjpbXX0.xm9eUrPqaDufNfg0k43NWzEWR0tlX41_223HHzDf6b8rh6g3-Z4duE5pIUFagAvB1lnmExYMZShEGW92K65bDETZ1dLTIe2VX2k1p2TxcRlUuriiXRMOGyiXurWiAibyenovMQwYqCxdBUIGBQo5hJyudQEoPrRjmQ9Lj9xh3DeoPhxO6OU1o6Bs4FKNY8YlX7JBzJImtp9azx0xrmyZGLArwvOkZ8JdTy4fIiSVjeFkuol33BkpjKq3mTHVDUBjbynoh26xxHdGu56sg2UAR_30ws_QsnrdtCK5ePjWuF9G5d1LdPaAfyWbsGyatkQp3NdAk5wRVPrQEo2VtK4qP9Iwkn1m5iLXsW5KvjgaUzNBoxYQtQNi7OuUWkGJK_3Hov9cUFgzTJNSXjpJDF4cgvKEV6hgUurt11UMiKc31OIPBNizZJqQt4KagxvsU_zO4cBllFQvci8i8-DoHZKQhBOebJqkVlXa_QY6gmt_jxg7kErwv_V5qWiGs2GQL01lI-HAmhJjhkrs3NoPw0CfKb8dMjFx9Zm4WkOjsHQwKTAiMEEHHEUOcdsIpK_wWeI9zM2oF4YM4phAAlrlKJVYIQ6NDyEXHCxapDxU2YxpAyWHhT-Rmx2sa9r0JTtpyGCmqHIMTulV2u9v7tWayd6STvflQv8_WzEb2jah5xrZyNo';

//    axios.defaults.baseURL = 'http://zz.wangwen.co';


    axios.defaults.headers.common['Authorization'] = token;

    axios.get('/api/me').then((response)=>{

        console.log(response.data);

    }).catch((error)=>{

        console.log(error.response);
    });


//    localStorage.set

//    localStorage.setItem('dd','dd');

    function getRecomment(position,limit,page) {
        axios.get('/api/books/hot_list',{
            params: {
                limit: limit,
                page:page
            }

        }).then(function (response) {
            console.log(response.data);
            console.log(response.data.access_token);

        }).catch(function (error) {
            console.log(error.response.data);

        });

    }

    axios.get('/api/books/hot_list',{
        params: {
            limit: 10,
            page:2
        }

    }).then(function (response) {
        console.log(response.data);
        console.log(response.data.access_token);

    }).catch(function (error) {
        console.log(error.response.data);

    });


    axios.post('/api/auth/login',{
        'phone':'13115181221',
        'password':'12345'

    }).then(function (response) {
        console.log(response.data);
        console.log(response.data.access_token);

    }).catch(function (error) {
        console.log(error.response.data);

    });



    function getParent(ele,tag) {


        var parent = ele.parentNode;

        if (parent == null){

            return null;

        }

        var tagName = parent.tagName.toLowerCase();
        var searchTag = tag.toLowerCase();

        console.log(tagName + '-' + searchTag);


        if (tagName === searchTag){
            return parent;

        }

        return getParent(parent,tag);

    }

    window.onload = function () {


        var label = document.getElementById("current");

        var li = getParent(label,'li');

        console.log(label);

        console.log(li);

        var comment = li.getElementsByClassName('comment');


//        comment.style.display = 'none';
        console.log(comment[0].style.display = 'none');
//        console.log(label.style.fontSize);


//        alert(label);
//        alert( label.style.getPropertyValue("font-size") );



    }

    // 打开新窗口
    function openWindow() {

        //以下为按钮点击事件的逻辑。注意这里要重新打开窗口
        //否则后面跳转到QQ登录，授权页面时会直接缩小当前浏览器的窗口，而不是打开新窗口
        window.open("oauth/redirect/driver/qq","TencentLogin",
            "width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");

        window.addEventListener("message", function(event) {

            console.log(event);
            if (! event.data){
                return;
            }
            console.log('获取到事件了');
            console.log(event.data);
            let token = event.data;
            // 保存token
            // 获取用户信息
        });


    }

    function  change(event,index) {

        var imgs = {
            1   :   './1.jpg',
            2   :   './2.jpg',
            3   :   './3.jpg'
        };

        var current = event.target.getElementsByTagName('img')[0];

        if (! current){
            return;
        }

        current.src = imgs[index];


    }

</script>
